<template>
	<view class="p-b-60">
		<u-cell-group title="当前状态" >
			<u-cell-item title="工作状态"  @click="$upStatusMoadl" :arrow="info.status==2?false:true" >
				<view class="" slot="right-icon">
					{{info.status_des|| '未知'}}
				</view>
			</u-cell-item>
			<u-cell-item title="当前订单ID" :value="info.now_order_id || '暂无'" :arrow="false"  ></u-cell-item>
		</u-cell-group>
		<u-cell-group title="个人信息">
			<u-cell-item title="申请时间" :value="info.create_time || '未知'" :arrow="false" ></u-cell-item>
			<u-cell-item title="司机姓名" :value="info.driver_name || '司机'" :arrow="false" ></u-cell-item>
			<u-cell-item title="联系方式" :value="getPhone(info.mobile) || '暂无'" :arrow="false"></u-cell-item>
			<u-cell-item title="身份证号" :value="getIdentity(info.id_card) || '暂无'" :arrow="false"></u-cell-item>
			<u-cell-item title="司机类型" :value="info.type == 1?'内部司机':'入驻司机'" :arrow="false"></u-cell-item>
			<u-cell-item title="司机等级" :value="info.level" :arrow="false"></u-cell-item>
			<u-cell-item title="司机奖金" :value="info.bonus==0?'暂无':info.bonus" :arrow="false"></u-cell-item>
			<u-cell-item title="司机积分" :value="info.integral==0?'暂无':info.integral" :arrow="false"></u-cell-item>
			<u-cell-item title="完成订单数量" :value="info.end_order || 0" :arrow="false"></u-cell-item>
		</u-cell-group>
		<u-cell-group title="代理商信息" >
			<u-cell-item title="区域代理ID" :value="info.shop_id|| '未知' " :arrow="false" ></u-cell-item>
			<u-cell-item title="代理商名称" :value="info.name || '暂无'" :arrow="false"></u-cell-item>
			<u-cell-item title="代理商联系名称" :value="info.nickname || '暂无'" :arrow="false"></u-cell-item>
			<u-cell-item title="代理商电话" :value="!!info.agency_mobile?getPhone(info.agency_mobile) :'暂无'" :arrow="false"></u-cell-item>
		</u-cell-group>
		<u-cell-group title="车辆信息">
			<u-cell-item title="车牌号" :value="car.licence || '暂无'" :arrow="false" ></u-cell-item>
			<u-cell-item title="车辆类型" :value="car.carConfig.car_name || '暂无'" :arrow="false" ></u-cell-item>
			<u-cell-item title="品牌型号" :value="car.brand_model || '暂无'" :arrow="false" ></u-cell-item>
		</u-cell-group>
		<u-cell-group title="证件照片">
			<u-cell-item title="身份证正面照"   :arrow="false" >
				<view class="" slot="right-icon">
					<u-avatar :src="info.id_card_front" ></u-avatar>
				</view>
			</u-cell-item>
			<u-cell-item title="身份证反面照"   :arrow="false" >
				<view class="" slot="right-icon">
					<u-avatar :src="info.id_card_contrary" ></u-avatar>
				</view>
			</u-cell-item>
			<u-cell-item title="车辆右前照"   :arrow="false" >
				<view class="" slot="right-icon">
					<u-avatar :src="car.right_img" ></u-avatar>
				</view>
			</u-cell-item>
			<u-cell-item title="车辆左前照"   :arrow="false" >
				<view class="" slot="right-icon">
					<u-avatar :src="car.left_img" ></u-avatar>
				</view>
			</u-cell-item>
			<u-cell-item title="驾驶证照片"   :arrow="false" >
				<view class="" slot="right-icon">
					<u-avatar :src="info.driving_licence" ></u-avatar>
				</view>
			</u-cell-item>
		</u-cell-group>
		
	</view>
</template>

<script>
	import {drInfo,changeWorkStatus} from '@/api/car'
	export default {
		data() {
			return {
				info:{},
				car:{}
			}
		},
		onLoad() {
			this.driverInfoFun();
			
		},
		methods: {
			driverInfoFun(){
				drInfo().then(res=>{
					this.info = res.data;
					this.car = res.data.car;
				})
			},
			$upStatusMoadl(){
				if(this.info.status==2){
					return 
				}
				
				uni.showModal({
					title:'提示',
					content:'是否切换工作状态',
					success:res=>{
						if(res.confirm){
							this.changeWorkStatusFun();
						}
					}
				})
			},
			changeWorkStatusFun(){
				
				changeWorkStatus({
					status:this.info.status==1?'3':'1'
				}).then(res=>{
					this.$toast({
						title:res.msg
					})
					this.driverInfoFun();
				})
			}
		},
		computed:{
			getPhone(phone){
				return function(phone){
					if(typeof phone!='undefined'){
						return phone.substr(0,3) + '****' + phone.substr(7)
					}
				}
			},
			getIdentity(){
				return function(a){
					if(typeof a!='undefined'){
						return a.substr(0,8) + '********' + a.substr(16)
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
